<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
<div id="app">
    <ul>
        <li v-for="(item,index) in arr">{{index + 1}}一线城市:{{item}}</li>
    </ul>
    <h2 v-for="item in vegetables" :title="item.name">{{item.name}}</h2>
    <input type="button" value="添加" @click="add">
    <input type="button" value="移除" @click="remove">
</div>
<!-- 开发环境版本，包含了有帮助的命令行警告 -->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el: "#app",
        data: {
            arr: ["北京", "上海", "深圳", "重庆"],
            vegetables: [{name: "香菇"}, {name: "鸡蛋"}, {name: "花菜"}]
        },
        methods: {
            add() {
                this.vegetables.push({name: "鸡腿菇"})
            },
            remove(){
                this.vegetables.pop();
            }
        }
    })
</script>
</body>

</html>